package com.acme.bankapp.email;

import java.util.LinkedList;
import java.util.List;

/**
 * Class is a email message queue.
 * Class used only in com.acme.bankapp.email package.
 *
 * @author S.Zhidkov
 */
class Queue {
    private List<Email> queue = new LinkedList<Email>();

    /**
     * Method adds new email message to the queue.
     *
     * @param email
     */
    public void add(Email email) {
        queue.add(email);
    }

    /**
     * Returns {@code true} if this queue contains no elements.
     *
     * @return {@code true} if this queue contains no elements
     */
    public boolean isEmpty() {
        return queue.isEmpty();
    }

    /**
     * Returns first email message from the queue and removes it from the queue.
     *
     * @return first email message
     * @throws IndexOutOfBoundsException if the email queue is empty
     */
    public Email removeFirst() {
        return queue.remove(0);
    }
}
